# coding=utf-8

completed_event_map = {
    "pt.spider": {
        "BestSeller": {"jobType": "emr", "jobName": "testing_triggerAnotherJob_steps"},
        "MostWishedFor": {"jobType": "ecs", "jobName": "browse-tree-node-processor-task", "jobVersion": "9"},
        "OfferList": [{"jobType": "api", "jobName": "testing_triggerApi", "url": "https://v68hs0jrzj.execute-api.us-east-2.amazonaws.com/prod/feeds"},
                      {"jobType": "emr", "jobName": "testing_triggerAnotherJob_steps"}]
    },
    "aws.emr": {
        "Spark_application:testing_triggerAnotherJob_steps": {"jobType": "emr", "jobName": "testing_runAfterEmrJobCompleted_steps"}
    },
    "pt.service": {
        "FeedsProduct": {"jobType": "api", "jobName": "https://xxxxxx"}
    }
}


def get_next_job(event):
    event_source = event['source']
    event_detail_name = event['detail']['name']
    next_triggered_job_name = completed_event_map[event_source][event_detail_name]
    return next_triggered_job_name

    # if event_name == "pt.spider":
    #     spiderName = event['detail']['name']
    #     if spiderName == "BestSeller":
    #         return "testing_triggerAnotherJob_steps"
    #     else:
    #         return None
    # elif event_name == "aws.emr":
    #     jobName = event['detail']['name']
    #     if jobName == "Spark_application:testing_triggerAnotherJob_steps":
    #         return "testing_runAfterEmrJobCompleted_steps"
    #     else:
    #         return None
